from logging import Manager

from django.db import models
from django.contrib.auth import get_user_model
# Create your models here.

User = get_user_model()

class BlogCategory(models.Model):
    objects = models.Manager()
    name = models.CharField(max_length=100)
    class Meta:
        verbose_name = '分类'
        verbose_name_plural = verbose_name

class Blog(models.Model):
    objects = models.Manager()
    title = models.CharField(max_length=100)
    content = models.TextField()
    pub_time = models.DateTimeField(auto_now_add=True)
    category = models.ForeignKey(BlogCategory, on_delete=models.CASCADE)
    author = models.ForeignKey(User, on_delete=models.CASCADE)
    class Meta:
        verbose_name = '文章'
        verbose_name_plural = verbose_name

class BlogComment(models.Model):
    objects = models.Manager()
    content = models.TextField()
    pub_time = models.DateTimeField(auto_now_add=True)
    blog = models.ForeignKey(Blog, on_delete=models.CASCADE)
    author = models.ForeignKey(User, on_delete=models.CASCADE)
    class Meta:
        verbose_name = '评论'
        verbose_name_plural = verbose_name